package com.allo2o.common.lepayEnum;

import org.apache.commons.lang.StringUtils;

/**
 * <ul>
 * 支付方式,支付宝用100开头, 微信用200开头
 * </ul>
 * Created by lubingbing on 16-5-24.
 *
 * @author lubingbing
 */
public enum PayTypeEnum {
    ALIPAY_QR_CODE("BARPAY", "支付宝扫码收款"), // 商户扫描顾客

    ALIPAY_SCAN("ALIQRPAY", "支付宝收款二维码"), // 客户扫打印二维码

    WECHAT_QR_CODE("BarPay", "微信扫码收款"), // 商户扫顾客

    WECHAT_SUBSCRIPTION("JsApiPay", "微信收款二维码"), // 顾客扫二维码

    PROFIT_SHARE("profit_share", "分润"), // 分润

    CASH_ACCOUNT("cash", "现金记账"); // 现金记账


    private String code;

    private String desc;

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    PayTypeEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static PayTypeEnum getEnumByCode(String code) {
        if (StringUtils.isBlank(code)) {
            return null;
        }
        PayTypeEnum[] arr = PayTypeEnum.values();
        for (PayTypeEnum anArr : arr) {
            if (anArr.getCode().equalsIgnoreCase(code)) {
                return anArr;
            }
        }
        return null;
    }
}
